# coding=utf-8
# 通过collections模块的Iterable类型判断：
# 记录 一些方法
from collections import Iterable

print(isinstance('abc', Iterable))
print(isinstance([1, 2, 3], Iterable))
print(isinstance(123, Iterable))

for i, value in enumerate(['A', 'B', 'C']):
    print(i, value)

for x, y in [(1, 1), (2, 4), (3, 9)]:
    print(x, y)

L = list(range(200))
L1 = L[0: 10]
for i, value in enumerate(L1[::3]):
    print(i, value)

print([x * x for x in range(1, 11)])
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
print([x * x for x in range(1, 11) if x % 2 == 0])
# [4, 16, 36, 64, 100]
print([m + n for m in 'ABC' for n in 'XYZ'])
# ['AX', 'AY', 'AZ', 'BX', 'BY', 'BZ', 'CX', 'CY', 'CZ']

import os  # 导入os模块，模块的概念后面讲到
# os.listdir可以列出文件和目录
print([d for d in os.listdir('.')])
# ['.idea', '.svn', 'app.py', 'dict.py', 'func.py', 'func1.py', 'ifelse.py', 'LICENSE', 'loop.py', 'pwd.py', 'README.md', 'seacode.py']


d = {'x': 'A', 'y': 'B', 'z': 'C'}
for k, v in d.items():
    print(k, '=', v)

x = 'abc'
y = 123
isinstance(x, str)
isinstance(y, str)

g = (x * x for x in range(10))
for n in g:
    print(n)
